﻿
using Dora.Orm.SqlSugarCore.UnitOfWork;
using Dora.Services.AdminUser.Dto.QueryDto;
using Dora.Services.AdminUser.Entities;
using Dora.Services.AdminUser.IApplication;
using Dora.Services.AdminUser.Repository.Repositorys;
using Dora.Services.AdminUser.Application.Base;
using Dora.Tools.Utility.Const;
using Microsoft.Extensions.Logging;
using Surging.Core.Common;
using Surging.Core.CPlatform.Ioc;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace Dora.Services.AdminUser.Application
{
    /// <summary>
    /// 旅行社组织机构用户映射表服务
    /// </summary>
    [ModuleName(DoraModuleName.AdminUser)]
    public class TasOrgUserMapService : DoraServiceBase, ITasOrgUserMapService
    {
        
        private ISugarUnitOfWork _unitOfWork;
        private readonly TasOrgUserMapRepository _repository;
        public TasOrgUserMapService(ISugarUnitOfWork unitOfWork)
        {
            _unitOfWork = unitOfWork;
            _repository = new TasOrgUserMapRepository(unitOfWork);
        }

        /// <summary>
        /// 根据Id获取一个实体对象
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="orgId"></param>
        /// <returns></returns>
        public async Task<TasOrgUserMapEntity> GetById(Guid userId, int orgId)
        {
            return await _repository.GetById(userId, orgId);
        }

        /// <summary>
        /// 根据orgId获取org的负责人TasOrgUserMap
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<TasOrgUserMapEntity> GetOrgLeaderByOrgId(int orgId)
        {
            var result = await _repository.GetOrgLeaderByOrgId(orgId);
            return result;
        }

        /// <summary>
        /// 修改是否需要编辑出团通知书
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="orgId"></param>
        /// <param name="isEditDepartureNotice"></param>
        /// <returns></returns>
        public async Task<bool> UpdateIsEditDepartureNotice(Guid userId, int orgId, bool isEditDepartureNotice)
        {
            var result = await _repository.UpdateIsEditDepartureNotice(userId, orgId, isEditDepartureNotice);
            return result;
        }

        /// <summary>
        /// 根据orgIdList获取TasOrgUserMapList
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<List<TasOrgUserMapEntity>> GetListByOrgIdList(List<int> orgIdList)
        {
            var result = await _repository.GetListByOrgIdList(orgIdList);
            return result;
        }
    }
}
